#! /usr/bin/python

def main():
    print str(reduce(lambda x,y:x+y**y,range(1,1001),0))[-10:]

if __name__ == '__main__':
    main()
    
